package com.googlecode.payroll

class PaymentCalculator {

    def calculate(workingHoursTotalizer, salesAmountTotalizer) {
        int totalWorkingHours = workingHoursTotalizer.workingHoursOf(id)
        int monthlyBase = hourlyRate * totalWorkingHours
        int totalSalesAmount = salesAmountTotalizer.salesAmountOf(id)
        int incentive = totalSalesAmount * incentivePercentage()
        monthlyBase + incentive
    }

    private def incentivePercentage() {
        switch(rank) {
            case Rank.SENIOR:
                return 0.03
            case Rank.MEMBER:
                return 0.02
            case Rank.NOVICE:
                return 0.01
        }
    }
}
